package 笔试;

import java.util.Scanner;

/**
 * @author:谢君臣
 * @Date:2021/4/2319:15
 * @version:1.0
 *
 *
 *
 * @function:
 */
public class T01 {

    public static void main(String[] args) {
        solution();
    }

    public static void solution() {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.next());
        int m = Integer.parseInt(scanner.next());
        int q = Integer.parseInt(scanner.next());
        int[][] arr = new int[n][m];
        int i = 0, j = 0,x = 0,y = 0;
        while (i < n) {
            while (j < m) arr[i][j++] = scanner.nextInt();
            i++;
            j = 0;
        }
        while (j < q) {
            x = scanner.nextInt()-1;
            y = scanner.nextInt()-1;
            if (arr[x][y] == 0)
                arr[x][y] = 1;
            else
                arr[x][y] = 0;
            int [] line = arr[x];
            getLenth(line);
            j++;
        }
    }

    private static void getLenth(int[] line) {
        int lenth = 0,i=0,j=0;
        while (j<line.length){
            if (line[i]==0)i = j;
            else {
                if (line[j]==0){
                    lenth = Math.max(lenth,j-i);
                    i = j;
                }else {
                    lenth = Math.max(lenth,j-i+1);
                }
            }
            j++;
        }
        System.out.println(lenth);
    }
}
